#include<iostream>
using namespace std;
int main()
{
	int n;
	int arr[1010] = { 0 };
	cin >> n;
	int sum = 0;
	int j = 0;
	for (int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for (j = 0; j <= sum; j++) {
			if (k <= arr[j]) {
				arr[j] = k;
				break;
			}
		}
		if (j > sum) {
			arr[sum++] = k;
		}
	}
	cout << sum << endl;
	return 0;
}